package com.shangxia.dog.base.service.impl;

import com.shangxia.dog.base.entity.Menu;
import com.shangxia.dog.base.mapper.MenuMapper;
import com.shangxia.dog.base.service.IMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author shangxia
 * @since 2022-02-03
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Value("${sys.param.userSysUser:false}")
    private Boolean sysUser;

    @Override
    public List<Menu> getMenuByAdminId(Long adminId) {
        if (!sysUser){
            return baseMapper.getMenuByAdminId(adminId);
        }
        return baseMapper.getAllMenus();
    }

    @Override
    public List<Menu> getMenusByRole() {
        return baseMapper.getMenusByRole();
    }

}
